/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved All rights reserved.
 */
package com.kaaction.modules.eb.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

import com.kaaction.common.persistence.TreeEntity;

/**
 * 分类Entity
 * @author zengbiao
 * @version 2017-04-19
 */
public class Classify extends TreeEntity<Classify> {
	
	private static final long serialVersionUID = 1L;
	private Classify parent;		// parent_id
	private String parentIds;		// parent_ids
	private String name;		// 名称
	private Integer sort;		// 排序值
	private String brief;		// 概述
	
	public Classify() {
		super();
	}

	public Classify(String id){
		super(id);
	}

	@JsonBackReference
	@NotNull(message="parent_id不能为空")
	public Classify getParent() {
		return parent;
	}

	public void setParent(Classify parent) {
		this.parent = parent;
	}
	
	@Length(min=1, max=4000, message="parent_ids长度必须介于 1 和 4000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@Length(min=1, max=64, message="名称长度必须介于 1 和 64 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@NotNull(message="排序值不能为空")
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	
	@Length(min=0, max=500, message="概述长度必须介于 0 和 500 之间")
	public String getBrief() {
		return brief;
	}

	public void setBrief(String brief) {
		this.brief = brief;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}